#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>
#include <QDebug>
#include <QMessageBox>
#include <QByteArray>

#include <QTcpSocket>
#include <QTcpServer>

#include <QJsonDocument>// 解析Json
#include <QJsonObject>// { }
#include <QJsonArray> // [ ]
#include <QJsonValue> // int float double bool null { } [ ]
#include <QJsonParseError>

namespace Ui {
class Widget;
}

class Widget : public QWidget
{
    Q_OBJECT

public:
    explicit Widget(QWidget *parent = 0);
    ~Widget();

private:
    Ui::Widget *ui;
    QTcpServer *server;
    QTcpSocket *socket=NULL;
    QJsonObject jsonConfig;

private:
    // 在类定义中添加常量（可选）
    static constexpr auto TEM_THRESHOLD_KEY = "tem_threshold";
    static constexpr auto HUM_THRESHOLD_KEY = "hum_threshold";
    static constexpr auto LIGHT_THRESHOLD_KEY = "light_threshold";
    static constexpr auto SMOKE_THRESHOLD_KEY = "smoke_threshold";

private slots:
    void openServerSlot();//开启服务槽函数
    void newConnectionSlot();//新连接槽函数
    void readMessageSlot();//读数据槽函数
    void sendMessageSlot();//发数据槽函数
    void disConnectSlot();//断开连接槽函数



};

#endif // WIDGET_H
